home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Apple Macintosh Developer Technical Support
- **
- ** Routines demonstrating how to call Gestalt.
- **
- ** by Mark Cookson, Apple Developer Technical Support
- **
- ** File: MyGestalt.c
- **
- ** Copyright ©1996 Apple Computer, Inc.
- ** All rights reserved.
- **
- ** You may incorporate this sample code into your applications without
- ** restriction, though the sample code has been provided "AS IS" and the
- ** responsibility for its operation is 100% yours. However, what you are
- ** not permitted to do is to redistribute the source as "Apple Sample
- ** Code" after having made changes. If you're going to re-distribute the
- ** source, we require that you make it clear in the source that the code
- ** was descended from Apple Sample Code, but that you've made changes.
- */
-
- #include "MyGestalt.h"
-
- OSErr InterrogateSystem (sGlobalsPtr globals)
- {
- long attrib = nil;
- OSErr theErr = noErr;
-
- if (TrapAvailable (_Gestalt)) {
- if (Gestalt (gestaltSoundAttr, &attrib) == noErr) {
- globals->ggestaltSoundAttr = attrib;
- }
- if (Gestalt (gestaltStandardFileAttr, &attrib) == noErr) {
- globals->ggestaltStandardFileAttr = attrib;
- }
- if (Gestalt (gestaltTranslationAttr, &attrib) == noErr) {
- globals->ggestaltTranslationAttr = attrib;
- }
- }
- else {
- theErr = kInitErr;
- }
-
- return theErr;
- }
-
- Boolean TrapAvailable (short trapWord)
- {
- TrapType tType;
- Boolean returnValue;
-
- if (BitAnd(trapWord, 0x0800)) {
- tType = ToolTrap;
- }
- else {
- tType = OSTrap;
- }
- if (tType == ToolTrap && (BitAnd(trapWord, 0x03FF) >= 0x200) &&
- GetToolboxTrapAddress(0xA86E) == GetToolboxTrapAddress(0xAA6E)) {
- returnValue = false;
- }
- else {
- returnValue = (NGetTrapAddress(trapWord, tType) != GetToolboxTrapAddress(_Unimplemented));
- }
-
- return returnValue;
- }
-